# Maintainer: Noel Kuntze <noel.kuntze@contauro.com>
pkgname=jigasi
pkgver=20240523
pkgrel=0
_gitrev=7a3211b5ccc127db6bb7c2032cd6937d8fb5dce5
pkgdesc="Jitsi meet SIP gateway"
url="https://github.com/jitsi/jigasi"
arch="x86_64"
license="Apache-2.0"
depends="openjdk11-jre-headless jicofo jitsi-videobridge jitsi-meet"
makedepends="maven"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/jitsi/jigasi/archive/$_gitrev.tar.gz
	$pkgname.initd
	$pkgname.confd
	$pkgname.logrotate
	"
builddir="$srcdir/jigasi-$_gitrev"
options="!check" # No test suite

build() {
	mvn clean
	mvn package -DskipTests -Dassembly.skipAssembly=true -Dmaven.repo.local="$builddir/.m2/repository"
	mvn dependency:copy-dependencies -DincludeScope=runtime -Dmaven.repo.local="$builddir/.m2/repository"
}

package() {
	DESTDIR="$pkgdir/usr/lib/$pkgname"
	CONFDIR="$pkgdir/etc/jitsi/jigasi"

	# dependencies, libraries and java launch files
	install -Dm644 -t "$DESTDIR/lib" target/dependency/*
	install -Dm644 target/jigasi-*-SNAPSHOT.jar "$DESTDIR/jigasi.jar"
	install -Dm755 -t "$DESTDIR" "jigasi.sh"
	install -Dm755 -t "$DESTDIR" "script/graceful_shutdown.sh"
	install -Dm755 -t "$DESTDIR" "script/collect-dump-logs.sh"


	# configuration
	install -dm700 "$CONFDIR"
	install -Dm640 -t "$CONFDIR" "lib/logging.properties" "jigasi-home/sip-communicator.properties"

	# init scripts and logrotate
	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
	install -m644 -D "$srcdir"/$pkgname.logrotate "$pkgdir"/etc/logrotate.d/$pkgname
}

sha512sums="
3b2055d0028bef575ce9672e585b909caeacfaeb81e42081d48aaa939bff91b4b674f671765a1eb198d4b098b6212e9157339adad240d02a0b9beaa8d2ba6351  jigasi-20240523.tar.gz
4785f72bc3c60488df409c292f1daffc583169138cf477253cbc80226da4d5b185a044d8d7d2b5bbe39290b852bf27e4443fa1a0eda55e9a385fcf7a53215748  jigasi.initd
2fc7bdcabbdf46c01c7edb02f22d76e972f9fa060999f8f120759cb78f64475d8d36ef7b07875cbcb2309f8d0220e5cdd86ab0a3ed1c050a50f8026ccea23009  jigasi.confd
9a3c97e983d1fc67bac3066a7f13cf043bd48e0448044c32ef8c6025f59d7df476ca22ffe305054d7d17c60a366eaa16ca653e1877a373eb1f896a863dd5e343  jigasi.logrotate
"
